<template>
  <view class="page container">
    <u-form
      :model="basicForm"
      :rules="rules"
      labelPosition="top"
      ref="form"
      labelWidth="auto"
      :labelStyle="{
        fontSize: '14px',
        color: '#B2B2B2',
        lineHight: '20px',
      }"
    >
      <view class="basic-style">
        <u-form-item label="档案名称" prop="archiveName" required>
          <u--input placeholder="请输入档案名称" v-model="basicForm.archiveName"></u--input>
        </u-form-item>
        <u-form-item label="纸质版数量" prop="paperVersionQuantity" required>
          <h-number-input placeholder="请输入纸质版数量" :min="0" :digit="0" v-model="basicForm.paperVersionQuantity"></h-number-input>
        </u-form-item>
        <u-form-item label="是否有电子版" prop="isElectronicVersion" :borderBottom="false" required>
          <h-dict-radio v-model="basicForm.isElectronicVersion" dictName="YES_OR_NO"></h-dict-radio>
        </u-form-item>
        <u-form-item label="备注" prop="remark">
          <u--textarea maxlength="500" :confirm-type="null" count v-model="basicForm.remark" placeholder="请输入备注"></u--textarea>
        </u-form-item>
      </view>

      <!-- <view class="space-x-1 mt-1" style="display: flex">
        <u-button type="primary" text="保存" :loading="loading" @click="onSubmit"></u-button>
        <u-button type="primary" text="关闭" :loading="loading" @click="onClose"></u-button>
      </view> -->
      <view class="space-x-1 mt-1" style="display: flex">
        <u-button type="primary" text="关闭" :plain="true" :loading="loading" @click="onClose"></u-button>
        <u-button type="primary" text="保存" :loading="loading" @click="onSubmit"></u-button>
      </view>
    </u-form>
  </view>
</template>

<script>
import http from '@/utils/request/index'

export default {
  name: 'PriceForm',
  components: {},
  props: {
    teamId: {
      type: [Number, String],
      default: '',
    },
    companyId: {
      type: [Number, String],
      default: '',
    },
    // 表单禁用
    disabled: {
      type: Boolean,
      default: false,
      required: false,
    },
    datailDisabled: {
      type: Boolean,
      default: false,
    },
    index: {
      type: Number,
      default: null,
    },
    progressVoList: {
      type: Array,
      default: () => [],
    },
  },
  data() {
    return {
      smallList: [],
      loading: false,
      basicForm: {
        archiveName: '',
        paperVersionQuantity: '',
        isElectronicVersion: '',
        remark: '',
      },
      rules: {
        archiveName: [{ required: true, message: '请输入档案名称!', trigger: ['blur', 'change'] }],
        paperVersionQuantity: [
          { type: 'number', required: true, message: '请输入纸质版数量!', trigger: ['blur', 'change'] },
        ],
        isElectronicVersion: [{ required: true, message: '请选择是否有电子版!', trigger: ['blur', 'change'] }],
      },
    }
  },
  created() {},
  computed: {},
  methods: {
    reset() {
      this.$refs.form.resetFields()
    },
    async onSubmit() {
      await this.$refs.form.validate()
      if (!this.index) {
        this.$emit('submit', [
          {
            id: parseInt(Math.random() * 1000000000000),
            ...this.basicForm,
          },
          this.index,
        ])
      } else {
        this.$emit('submit', [this.basicForm, this.index])
      }
      this.reset()
    },
    onClose() {
      this.$emit('close')
      this.reset()
    },
  }
}
</script>

<style scoped></style>
